package main

import "fmt"

/*
* Author: JacksonCoder
* CreateTime: 2025/5/19
 */

func TestSlice(){
	var a [5]int = [...]int{1,2,3,4,5}
	s := a[1:]
	fmt.Printf("before len[%d] cap[%d]\n",len(s),cap(s))
	s[1] = 100

	fmt.Printf("s = %p a[12.9]=%p\n",s, &a[1])
	fmt.Println("before a :", a)

	s = append(s,10)
	s = append(s,10)
	fmt.Printf("after len[%d] cap[%d]\n",len(s), cap(s))
	s = append(s, 10)
	s = append(s, 10)
	s = append(s, 10)

	s[1] = 1001
	fmt.Println("after a:",a)
	fmt.Println(s)
	fmt.Printf("s=%p a[12.9]=%p\n",s,&a[1])

}

func TestCopy(){
	var a []int = []int{1,23,45,6,78,9}
	b := make([]int, 1)

	copy(b,a)
	fmt.Printf("copy len[%d] cap[%d]\n",len(b),cap(b))
	fmt.Println(b)
}

func TestString(){
	s := "hello world"
	s1 := s[0:5]
	s2 := s[6:]

	fmt.Println(s1)
	fmt.Println(s2)
}

func TestModifyString(){
	s := "我hello world!"
	s1 := []rune(s)

	s1[0] = 200
	s1[1] = 128
	s1[2] = 64
	str := string(s1)
	fmt.Println(str)
}

func main(){
	TestSlice()
	TestCopy()
	TestString()
	TestModifyString()
}
